package com.horoscope.astrology.zodiac.signs.free.utils;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Base64;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;

import androidx.core.app.NotificationCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.horoscope.astrology.zodiac.signs.free.AppSettingManager;
import com.horoscope.astrology.zodiac.signs.free.BuildConfig;
import com.horoscope.astrology.zodiac.signs.free.MmoApplication;
import com.horoscope.astrology.zodiac.signs.free.MmoConstant;

import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SysUtils {

//    public static String MODEL_NAME;
//    public static String VERSION_NAME;
//    public static String APP_VERSION_NAME;
//    public static int APP_VERSION_CODE;
//    public static String BRAND_NAME;
//    public static String MANIFACTURE_NAME;
//    public static int WIDTH;
//    public static int HEIGHT;
//    public static float DENSITY;
//
//    public static String SOURCE = null;

    private SysUtils() {
    }

//    /**
//     * Initialize class from telephone configuration.
//     *
//     * @param ctx
//     */
//    public static void initialize(@NonNull Context ctx) {
//
//
//        MODEL_NAME = Build.DEVICE;
//        VERSION_NAME = Build.VERSION.RELEASE;
//        try {
//            PackageInfo pInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
//            APP_VERSION_NAME = pInfo.versionName;
//            APP_VERSION_CODE = pInfo.versionCode;
//        } catch (NameNotFoundException e1) {
//            e1.printStackTrace();
////          APP_VERSION_NAME = BuildConfig.VERSION_NAME;
//        }
//
//        BRAND_NAME = Build.BRAND;
//        MANIFACTURE_NAME = Build.MANUFACTURER;
//
//        try {
//            WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
//            Display display = wm.getDefaultDisplay();
//            Point size = new Point();
//            display.getSize(size);
//            WIDTH = size.x;
//            HEIGHT = size.y;
//            DisplayMetrics metric = new DisplayMetrics();
//            display.getMetrics(metric);
//            DENSITY = metric.density;
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//    public static boolean checkSDValid(Context context) {
//        try {
//            String state = Environment.getExternalStorageState();
//            if (Environment.MEDIA_MOUNTED.equals(state)) {
//                File tmp = new File(Environment.getExternalStorageDirectory(), "__af_tmp");
//                if (tmp.exists())
//                    tmp.delete();
//                if (tmp.createNewFile()) {
//                    tmp.delete();
//                }
//                return true;
//            }
//        } catch (Throwable e) {
//            e.printStackTrace();
//        }
//        return false;
//
//    }

    /**
     * 获取当前时区
     */
    public static String getCurrentTimeZone() {
        TimeZone tz = TimeZone.getDefault();
        tz.getID();

        return tz.getDisplayName(false, TimeZone.SHORT);
    }

//    public static String getCurrentTimeZoneCity() {
//        TimeZone tz = TimeZone.getDefault();
//        return tz.getID();
//    }
//
//    /**
//     * 获取当前系统语言格式
//     *
//     * @param mContext
//     * @return
//     */
//    public static String getCurrentLanguage(Context mContext) {
//        Locale locale = mContext.getResources().getConfiguration().locale;
//        String language = locale.getLanguage();
//        String country = locale.getCountry();
//        String lc = language;
//        return lc;
//    }

    /**
     * 获得设备硬件标识
     *
     * @param context 上下文
     * @return 设备硬件标识
     */
    public static String getDeviceUniqueID(Context context) {
        StringBuilder sbDeviceId = new StringBuilder();

        //获得设备默认IMEI（>=6.0 需要ReadPhoneState权限）
//        String imei = getIMEI(context);
        //获得AndroidId（无需权限）
        String androidid = getAndroidId(context);
        //获得设备序列号（无需权限）
        String serial = getSERIAL();
        //获得硬件uuid（根据硬件相关属性，生成uuid）（无需权限）
        String uuid = getDeviceUUID().replace("-", "");

        //追加imei
//        if (imei != null && imei.length() > 0) {
//            sbDeviceId.append(imei);
//            sbDeviceId.append("|");
//        }
        //追加androidid
        if (androidid != null && androidid.length() > 0) {
            sbDeviceId.append(androidid);
            sbDeviceId.append("|");
        }
        //追加serial
        if (serial != null && serial.length() > 0) {
            sbDeviceId.append(serial);
            sbDeviceId.append("|");
        }
        //追加硬件uuid
        if (uuid.length() > 0) {
            sbDeviceId.append(uuid);
        }

        //生成SHA1，统一DeviceId长度
        if (sbDeviceId.length() > 0) {
            try {
                byte[] hash = getHashByString(sbDeviceId.toString());
                String sha1 = bytesToHex(hash);
                if (sha1.length() > 0) {
                    //返回最终的DeviceId
                    return sha1;
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

        //如果以上硬件标识数据均无法获得，
        //则DeviceId默认使用系统随机数，这样保证DeviceId不为空
        return UUID.randomUUID().toString().replace("-", "");
    }

    //需要获得READ_PHONE_STATE权限，>=6.0，默认返回null
//    private static String getIMEI(Context context) {
//        try {
//            TelephonyManager tm = (TelephonyManager)
//                    context.getSystemService(Context.TELEPHONY_SERVICE);
//            return tm.getDeviceId();
//        } catch (Exception ex) {
//            ex.printStackTrace();
//        }
//        return "";
//    }

    /**
     * 获得设备的AndroidId
     *
     * @param context 上下文
     * @return 设备的AndroidId
     */
    private static String getAndroidId(Context context) {
        try {
            return Settings.Secure.getString(context.getContentResolver(),
                    Settings.Secure.ANDROID_ID);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return "";
    }

    /**
     * 获得设备序列号（如：WTK7N16923005607）, 个别设备无法获取
     *
     * @return 设备序列号
     */
    private static String getSERIAL() {
        try {
            return Build.SERIAL;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return "";
    }

    /**
     * 获得设备硬件uuid
     * 使用硬件信息，计算出一个随机数
     *
     * @return 设备硬件uuid
     */
    private static String getDeviceUUID() {
        try {
            String dev = "3883756" +
                    Build.BOARD.length() % 10 +
                    Build.BRAND.length() % 10 +
                    Build.DEVICE.length() % 10 +
                    Build.HARDWARE.length() % 10 +
                    Build.ID.length() % 10 +
                    Build.MODEL.length() % 10 +
                    Build.PRODUCT.length() % 10 +
                    Build.SERIAL.length() % 10;
            return new UUID(dev.hashCode(),
                    Build.SERIAL.hashCode()).toString();
        } catch (Exception ex) {
            ex.printStackTrace();
            return "";
        }
    }

    /**
     * 取SHA1
     *
     * @param data 数据
     * @return 对应的hash值
     */
    private static byte[] getHashByString(String data) {
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
            messageDigest.reset();
            messageDigest.update(data.getBytes(StandardCharsets.UTF_8));
            return messageDigest.digest();
        } catch (Exception e) {
            return "".getBytes();
        }
    }

    /**
     * 转16进制字符串
     *
     * @param data 数据
     * @return 16进制字符串
     */
    private static String bytesToHex(byte[] data) {
        StringBuilder sb = new StringBuilder();
        String stmp;
        for (byte datum : data) {
            stmp = (Integer.toHexString(datum & 0xFF));
            if (stmp.length() == 1)
                sb.append("0");
            sb.append(stmp);
        }
        return sb.toString().toUpperCase(Locale.CHINA);
    }

    public static void startFeedback(Context context) {
        String systemVersion = "Android: " + Build.VERSION.RELEASE;
        String deviceInfo = "Device: " + Build.BRAND;
        String appName = "App Name: Horoscope_Android";
        String appVersion = "App Version: " + getAppVersion();
        String language = "Language: " + Locale.getDefault().getLanguage();
        String country = "Country: " + Locale.getDefault().getDisplayCountry();
        Intent feedbackIntent = new Intent();
        feedbackIntent.setData(Uri.parse("mailto:"));
        String[] receiver = new String[]{MmoConstant.FEED_BACK_ADDRESS};
        feedbackIntent.putExtra(Intent.EXTRA_EMAIL, receiver);
        feedbackIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
        feedbackIntent.putExtra(Intent.EXTRA_TEXT
                , "\n\n\n\n\n\n" + appName + "\n" + appVersion + "\n" + systemVersion + "\n" +
                        language + "\n" + country + "\n" + deviceInfo);
        feedbackIntent.setAction(Intent.ACTION_SENDTO);
        context.startActivity(Intent.createChooser(feedbackIntent, "Share By:"));
    }

//    /**
//     * 判断是否安装twitter
//     *
//     * @param context
//     * @return
//     */
//    public boolean isInstallTwitter(Context context) {
//        PackageInfo packageInfo;
//        try {
//            packageInfo = context.getPackageManager().getPackageInfo("com.twitter.android", 0);
//        } catch (NameNotFoundException e) {
//            packageInfo = null;
//            e.printStackTrace();
//        }
//        return packageInfo != null;
//
//    }

    public static boolean isInstallFacebook(Context context) {
        PackageInfo packageInfo;
        try {
            packageInfo = context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
        } catch (NameNotFoundException e) {
            packageInfo = null;
            e.printStackTrace();
        }
        return packageInfo != null;
    }

//    /**
//     * 只用于把字符串最后一个字符变成红色
//     *
//     * @param string
//     * @return
//     */
//    public static SpannableString getColorSpan(String string) {
//        SpannableString spanStr = new SpannableString(string);
//        spanStr.setSpan(new ForegroundColorSpan(Color.rgb(255, 81, 13)), string.length() - 1, string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//        return spanStr;
//    }
//    public static String editTextForm(String string) {
//        String str = string.replace("\n", " ").trim();
//        return str;
//    }


    /**
     * 判断多次快速点击
     */
    private static final float MIN_DELAY_TIME = 1000L;  // 两次点击间隔不能少于_ ms
    private static long lastClickTime;

    public static boolean isFastClick() {
        boolean flag = true;
        long currentClickTime = System.currentTimeMillis();
        if ((currentClickTime - lastClickTime) >= MIN_DELAY_TIME) {
            flag = false;
        }
        lastClickTime = currentClickTime;
        return flag;
    }

    /**
     * 输入字符串（比如：23：45：12）
     * 输出 毫秒
     */
    public static int getTime(String str) {
        try {
            if (str.length() == 0) {
                return 0;
            }
            String hh = str.substring(0, 2);
            String mm = str.substring(3, 5);
            String ss = str.substring(6, 8);
            int result = Integer.parseInt(hh) * 3600 + Integer.parseInt(mm) * 60 + Integer.parseInt(ss);
            return result * 1000;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }

    public static int rp(float dip) {
        Context c = MmoApplication.Companion.getInstance();
        if (dip > 0) {
            return (int) (c.getResources()
                    .getDisplayMetrics().density * dip + 0.5f);
        } else {
            return (int) dip;
        }
    }

    public static int dp2sp(int value, Context context) {
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, value, context.getResources().getDisplayMetrics());

    }


//    public static int getSystemBrightness(Context context) {
//        int systemBrightness = 0;
//        try {
//            systemBrightness = Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
//        } catch (Settings.SettingNotFoundException e) {
//            e.printStackTrace();
//        }
//        return systemBrightness;
//    }
//
//    /**
//     * 获取当前的网络状态 ：没有网络-0：WIFI网络1：4G网络-4：3G网络-3：2G网络-2
//     * 自定义
//     *
//     * @param context
//     * @return
//     */
//    public static boolean isDeviceConnectWifi(Context context) {
//        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
//        if (manager == null) {
//            return false;
//        }
//        NetworkInfo networkInfo = manager.getActiveNetworkInfo();
//        if (networkInfo == null) {
//            return false;
//        }
//        int nType = networkInfo.getType();
//        if (nType == ConnectivityManager.TYPE_WIFI) {
//            //WIFI
//            return true;
//        }
//        return false;
//    }
//    public static boolean isCharging(Context context) {
//        IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
//        Intent batteryStatus = context.registerReceiver(null, filter);
//        int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
//        return status == BatteryManager.BATTERY_STATUS_CHARGING;
//    }

    public static String createNotificationChannel(Context context, boolean screenOn) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            String channelId = "channelId" + screenOn;
            CharSequence channelName = "channelName";
            String channelDescription = "channelDescription";
            int channelImportance = NotificationManager.IMPORTANCE_DEFAULT;

            NotificationChannel notificationChannel = new NotificationChannel(channelId, channelName, channelImportance);
            // 设置描述 最长30字符
            notificationChannel.setDescription(channelDescription);
            // 该渠道的通知是否使用震动
            notificationChannel.enableVibration(true);
            if (screenOn) {
                notificationChannel.setSound(null, null);
            }
            // 设置显示模式
            notificationChannel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC);

            NotificationManager notificationManager =
                    (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.createNotificationChannel(notificationChannel);

            return channelId;
        } else {
            return null;
        }
    }

//    public static void senEmail(Context contextCompat) {
//        Intent intent = new Intent(Intent.ACTION_SEND);
//        String[] receiver = {"makemoneyrewardsonline@outlook.com"};
//        intent.putExtra(Intent.EXTRA_EMAIL, receiver);
//        intent.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
//        intent.putExtra(Intent.EXTRA_TEXT, "\n\n\n\n\n\n\n\n\n\n\nAndroid:" + getSystemVersion()
//                + "\nPhone:" + getSystemModel() + "" +
//                "\nApp Version:" + getAppVersion());
//
//        intent.setType("text/plain");
//        //intent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(file))
//        contextCompat.startActivity(Intent.createChooser(intent, "Select Email"));
//    }

    public static String getSystemVersion() {
        return Build.VERSION.RELEASE;
    }

    public static String getSystemModel() {
        return Build.MODEL;
    }

    public static String getAppVersion() {
        return BuildConfig.VERSION_NAME;
    }

//    public static int getAppVersionCode() {
//        return BuildConfig.VERSION_CODE;
//    }
//
//    public static String getCountry() {
//        return "";
//    }

    public static int getScreenWidthPixels(Context context) {
        if (context == null) return 0;
        Resources resources = context.getResources();
        DisplayMetrics dm = resources.getDisplayMetrics();
        return dm.widthPixels;
    }

    public static int getScreenHeightPixels(Context context) {
        Resources resources = context.getResources();
        DisplayMetrics dm = resources.getDisplayMetrics();
        return dm.heightPixels;
    }


    public static boolean isContainChinese(String str) {
        Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
        Matcher m = p.matcher(str);
        if (m.find()) {
            return true;
        }
        return false;
    }

    /**
     * 获取秘钥散列
     */
//    public static void printKeyHash(Activity activity) {
//        try {
//            int i = 0;
//            PackageInfo info = activity.getPackageManager().getPackageInfo(activity.getPackageName(), PackageManager.GET_SIGNATURES);
//            for (Signature signature : info.signatures) {
//                i++;
//                MessageDigest md = MessageDigest.getInstance("SHA");
//                md.update(signature.toByteArray());
//                String KeyHash = Base64.encodeToString(md.digest(), Base64.DEFAULT);
//                //KeyHash 就是你要的，不用改任何代码  复制粘贴 ;
//                Log.e("tyl", "KeyHash=" + KeyHash);
//                System.out.println(KeyHash);
//                Toast.makeText(activity, KeyHash, Toast.LENGTH_LONG).show();
//            }
//
//        } catch (PackageManager.NameNotFoundException e) {
//
//        } catch (NoSuchAlgorithmException e) {
//            e.printStackTrace();
//        }
//    }

//    public static void CountAppOpenTime() {
//        int timeNum = AppSettingManager.INSTANCE.readInt("openAppTime", 0);
//        timeNum++;
//        AppSettingManager.INSTANCE.saveInt(timeNum,"openAppTime");
//    }
    public static String getStringDate() {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = formatter.format(currentTime);
        return dateString;
    }

    public static Bitmap stringtoBitmap(String string) {
        Bitmap bitmap = null;
        try {
            byte[] bitmapArray;
            bitmapArray = Base64.decode(string, Base64.DEFAULT);
            bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return bitmap;
    }

    public static String getCurrentHour() {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("HH:mm");
        String data = format.format(date);
        Log.d("DDDtrEEEE", data);
        String res = data.substring(0, 2);
        if (Integer.valueOf(res) > 12) {
            res = (Integer.valueOf(res) - 12) + "";
        }
        return res;
    }

    public static String getCurrentMin() {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("HH:mm");
        String data = format.format(date);
        String res = data.substring(3, 5);
        return res;
    }


    public static int getAMOrPM() {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("HH:mm");
        String data = format.format(date);
        Log.d("DDDtrEEEE", data);
        String res = data.substring(0, 2);
        if (Integer.valueOf(res) > 12) {
            return 1;
        }
        return 0;
    }


    public static void doShareLink(Activity activity, String text, String link) {
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        Intent chooserIntent = Intent.createChooser(shareIntent, "share");

        // for 21+, we can use EXTRA_REPLACEMENT_EXTRAS to support the specific case of Facebook
        // (only supports a link)
        // >=21: facebook=link, other=text+link
        // <=20: all=link
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            shareIntent.putExtra(Intent.EXTRA_TEXT, text + " " + link);
            Bundle facebookBundle = new Bundle();
            facebookBundle.putString(Intent.EXTRA_TEXT, link);
            Bundle replacement = new Bundle();
            replacement.putBundle("com.facebook.katana", facebookBundle);
            chooserIntent.putExtra(Intent.EXTRA_REPLACEMENT_EXTRAS, replacement);
        } else {
            shareIntent.putExtra(Intent.EXTRA_TEXT, link);
        }

        chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(chooserIntent);
    }

    // 获取下一年
    public static String getNexYear() {
        TimeZone tz = TimeZone.getDefault();
        createGmtOffsetString(true, true, tz.getRawOffset());
        return String.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 1);
    }

    private static String createGmtOffsetString(
            boolean includeGmt, boolean includeMinuteSeparator, int offsetMillis) {
        int offsetMinutes = offsetMillis / 60000;
        char sign = '+';
        if (offsetMinutes < 0) {
            sign = '-';
            offsetMinutes = -offsetMinutes;
        }
        StringBuilder builder = new StringBuilder(9);
        if (includeGmt) {
            builder.append("GMT");
        }
        builder.append(sign);
        appendNumber(builder, 2, offsetMinutes / 60);
        if (includeMinuteSeparator) {
            builder.append(':');
        }
        appendNumber(builder, 2, offsetMinutes % 60);
        return builder.toString();
    }

    // 将数字添加到GMT后
    private static void appendNumber(StringBuilder builder, int count, int value) {
        String string = Integer.toString(value);
        for (int i = 0; i < count - string.length(); i++) {
            builder.append("0");
        }
        builder.append(string);
    }

    /**
     * 判断应用是否已经启动
     *
     * @param context     上下文对象
     * @param packageName 要判断应用的包名
     * @return boolean
     */
    public static boolean isAppAlive(Context context, String packageName) {
        ActivityManager activityManager =
                (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningAppProcessInfo> processInfos
                = activityManager.getRunningAppProcesses();
        for (int i = 0; i < processInfos.size(); i++) {
            if (processInfos.get(i).processName.equals(packageName)) {
                return true;
            }
        }

        return false;
    }

    // 安装当日零点
    public static Long zeroClockOnTheDay() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        return calendar.getTimeInMillis();
    }


    /*
    * // 获取下一年
    fun getNexYear(): String {
        val tz = TimeZone.getDefault()
        val c = Calendar.getInstance()
        c.timeZone = TimeZone.getTimeZone(createGmtOffsetString(true, true, tz.rawOffset))
        return (c.get(Calendar.YEAR) + 1).toString()
    }

    // 获取GEM开头的时区
    fun createGmtOffsetString(
        includeGmt: Boolean,
        includeMinuteSeparator: Boolean,
        offsetMillis: Int
    ): String {
        var offsetMinutes = offsetMillis / 60000
        var sign = '+'
        if (offsetMinutes < 0) {
            sign = '-'
            offsetMinutes = -offsetMinutes
        }
        val builder = StringBuilder(9)
        if (includeGmt) {
            builder.append("GMT")
        }
        builder.append(sign)
        appendNumber(builder, 2, offsetMinutes / 60)
        if (includeMinuteSeparator) {
            builder.append(':')
        }
        appendNumber(builder, 2, offsetMinutes % 60)
        return builder.toString()
    }

    // 将数字添加到GMT后
    private fun appendNumber(builder: StringBuilder, count: Int, value: Int) {
        val string = Integer.toString(value)
        for (i in 0 until count - string.length) {
            builder.append('0')
        }
        builder.append(string)
    }
    * */

    /**
     * 判断App当日是否首次登陆
     *
     * @param dataName      对应数据存储名
     * @param constellation 星座名
     * @return boolean
     */
    public static Boolean isTodayFirstLogin(String constellation, String dataName) {
        String lastDate = AppSettingManager.INSTANCE.readString(dataName, "2020-01-01");
        String compare = AppSettingManager.INSTANCE.readString("CompareConstellation", "Leo");
        String currentDate = getStringDate();
        return !lastDate.equals(currentDate) || !compare.equals(constellation);
    }

    /**
     * 当天的 3:20pm
     *
     * @return
     */
    public static long startOfTodDay() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        Date date = calendar.getTime();
        return date.getTime() + 55200000L;
    }

    //反射设定RecyclerView最大滑动速度
    public static void setMaxFlingVelocity(RecyclerView recycleview, int velocity) {
        try{
            Field field = recycleview.getClass().getDeclaredField("mMaxFlingVelocity");
            field.setAccessible(true);
            field.set(recycleview, velocity);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}